/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.companhia.controller;

import br.com.companhia.interfaces.IEndereco;
import br.com.companhia.model.Endereco;
import br.com.companhia.util.DAOFactory;
import java.util.List;

/**
 *
 * @author Andre
 */

public class EnderecoController {
    
    private IEndereco enderecoDAO;

    public EnderecoController() {
        enderecoDAO = DAOFactory.criarEnderecoDAO();
    }
    
     public Endereco carregar(int id){
        return enderecoDAO.carregar(id);
    }
    
    public void salvar(Endereco endereco){
        Integer id = endereco.getId();
        if(id == null || id == 0){
            enderecoDAO.salvar(endereco);
        } else {
            enderecoDAO.atualizar(endereco);
        }
    }
    
    public void excluir(Endereco endereco){
        enderecoDAO.excluir(endereco);
    }
    
    public List<Endereco> listar(){
        return enderecoDAO.listar();
    }
    
}
